import 'package:flutter/material.dart';
import 'skeleton_animation.dart';

/// Create by kyluzoi
/// Date: 2021-08-16
///
/// Description: 骨架屏装饰器
///

class SkeletonDecoration extends BoxDecoration {
  SkeletonDecoration({
    required List<Color> colors,
    isAnimation: true,
    required SkeletonAnimation animation,
    isCircle: false,
  }) : super(
            shape: isCircle ? BoxShape.circle : BoxShape.rectangle,
            color: isAnimation ? null : colors[0],
            gradient: isAnimation
                ? LinearGradient(
                    begin: Alignment.topLeft,
                    end: Alignment.bottomRight,
                    colors: colors,
                    stops: [
                      animation.animation.value - 1,
                      animation.animation.value,
                      animation.animation.value + 1
                    ],
                  )
                : null);
}
